using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using System.IO;
using System.Windows.Forms;

namespace Rapier.Kodachi.Core.Actions
{
    public class CopyToClipboard : Action
    {
        #region Constructor
        public CopyToClipboard(Plugin plugin)
            : base(plugin, "Rapier.CorePlugin.CopyToClipboard", "Copy to Clipboard", "Copies item to the clipboard.")
        {
            GetImage = delegate() { return Resource.Clipboard; };
        }
        #endregion

        #region Action Members
        public override bool IsValidDirect(Item directItem)
        {
            return !directItem.Properties.ContainsKey("SystemCommand");
        }

        public override void Execute(Item[] directItems, Item[] indirectItems)
        {
            foreach (Item directItem in directItems)
            {
                if (directItem.Properties.ContainsKey("ClipboardData"))
                    Clipboard.SetDataObject(directItem.Properties["ClipboardData"]);
                else if (directItem.Properties.ContainsKey("Text"))
                    Clipboard.SetText(directItem.Properties["Text"].ToString());
                else
                    Clipboard.SetText(directItem.Name); 
            }
        }
        #endregion
    }
}
